CDRIVER-4584 support Queryable Encryption v2 #1228
Merged
kevinAlbs merged 14 commits intomongodb:masterfrom Apr 6, 2023
Merged
CDRIVER-4584 support Queryable Encryption v2 #1228kevinAlbs merged 14 commits intomongodb:masterfrom
kevinAlbs merged 14 commits intomongodb:masterfrom
Conversation
To enable the featureFlagFLE2ProtocolVersion2 until it is enabled by default in SERVER-69563
Syncs to specifications commit 64deb2837a2355f6002775c49b9b6c50c9dc560f
remove unnecessary wire version checks server version is now checked in the function call
eramongodb
reviewed
Mar 31, 2023
Co-authored-by: Ezra Chung <88335979+eramongodb@users.noreply.github.com>
eramongodb
approved these changes
Apr 4, 2023
Comment on lines
+19
to
+27
| if "procParams" in server: | ||
| if "setParameter" in server["procParams"]: | ||
| server["procParams"]["setParameter"]["featureFlagFLE2ProtocolVersion2"] = "1" | ||
| else: | ||
| server["procParams"]["setParameter"] = { | ||
| "featureFlagFLE2ProtocolVersion2": "1" | ||
| } | ||
| return True | ||
| return False |
Contributor
There was a problem hiding this comment.
Suggested change
| if "procParams" in server: | |
| if "setParameter" in server["procParams"]: | |
| server["procParams"]["setParameter"]["featureFlagFLE2ProtocolVersion2"] = "1" | |
| else: | |
| server["procParams"]["setParameter"] = { | |
| "featureFlagFLE2ProtocolVersion2": "1" | |
| } | |
| return True | |
| return False | |
| params = server.get("procParams") | |
| if params is None: | |
| return False | |
| setParams = params.setdefault("setParameter", {}) | |
| setParams["featureFlagFLE2ProtocolVersion2"] = "1" | |
| return True |
Dict.get returns None if the key is absent. Dict.setdefault(K, V) returns the existing value if present or performs Dict[K] = V, and then returns Dict[V]. dicts are by-reference mutable.
vector-of-bool
approved these changes
Apr 5, 2023
Contributor
vector-of-bool
left a comment
There was a problem hiding this comment.
LGTM, although I got distracted by the Python code.
| raise Exception( | ||
| "Did not add setParameter. Does the orchestration config have `procParams`?" | ||
| ) | ||
| pass |
Contributor
There was a problem hiding this comment.
Suggested change
| pass |
Comment on lines
+29
to
+55
| # Rewrite for a server. | ||
| if rewrite_server(config): | ||
| did_rewrite = True | ||
| # Rewrite for each member in a replica set. | ||
| if "members" in config: | ||
| for server in config["members"]: | ||
| if rewrite_server(server): | ||
| did_rewrite = True | ||
| # Rewrite each shard. | ||
| if "shards" in config: | ||
| for shard in config["shards"]: | ||
| if "shardParams" in shard: | ||
| if "members" in shard["shardParams"]: | ||
| for server in shard["shardParams"]["members"]: | ||
| if rewrite_server (server): | ||
| did_rewrite = True | ||
| # Rewrite each router. | ||
| if "routers" in config: | ||
| for router in config["routers"]: | ||
| # routers do not use `procParams`. Use setParameter directly. | ||
| if "setParameter" in router: | ||
| router["setParameter"]["featureFlagFLE2ProtocolVersion2"] = "1" | ||
| else: | ||
| router["setParameter"] = { | ||
| "featureFlagFLE2ProtocolVersion2": "1" | ||
| } | ||
| did_rewrite = True |
Contributor
There was a problem hiding this comment.
I got nerd-sniped into flattening this code :)
Suggested change
| # Rewrite for a server. | |
| if rewrite_server(config): | |
| did_rewrite = True | |
| # Rewrite for each member in a replica set. | |
| if "members" in config: | |
| for server in config["members"]: | |
| if rewrite_server(server): | |
| did_rewrite = True | |
| # Rewrite each shard. | |
| if "shards" in config: | |
| for shard in config["shards"]: | |
| if "shardParams" in shard: | |
| if "members" in shard["shardParams"]: | |
| for server in shard["shardParams"]["members"]: | |
| if rewrite_server (server): | |
| did_rewrite = True | |
| # Rewrite each router. | |
| if "routers" in config: | |
| for router in config["routers"]: | |
| # routers do not use `procParams`. Use setParameter directly. | |
| if "setParameter" in router: | |
| router["setParameter"]["featureFlagFLE2ProtocolVersion2"] = "1" | |
| else: | |
| router["setParameter"] = { | |
| "featureFlagFLE2ProtocolVersion2": "1" | |
| } | |
| did_rewrite = True | |
| import itertools | |
| # We will rewrite the root config: | |
| root = [config] | |
| # And any top-level members: | |
| root_members = config.get("members", []) | |
| # As well as the members within any defined shards: | |
| shards = config.get("shards", []) | |
| # Get a list of lists of membres: | |
| shard_member_lists = (s.get("shardParams", {}).get("members", []) for s in shards) | |
| # Flatten the list of lists: | |
| shard_members = itertools.chain.from_iterable(shard_member_lists) | |
| # For all members in all groups: | |
| all_members = itertools.chain(root, root_members, shard_members) | |
| # Rewrite them all: | |
| all_rewrites = list(map(rewrite_server, all_members)) | |
| # Did we actually rewrite anything? | |
| did_rewrite = any(all_rewrites) | |
| # Rewrite each router. | |
| for rtr in config.get("routers", []): | |
| ps = rtr.setdefault("setParameter", {}) | |
| ps["featureFlagFLE2ProtocolVersion2"] = "1" | |
| did_rewrite = True |
Collaborator
Author
There was a problem hiding this comment.
Oh that is really neat. I did not know about itertools.chain.
This reverts commit aa82b19.
Collaborator
Author
|
The setfle2parameter.py has has been removed now that the feature flag is enabled on servers by default: DRIVERS-2590 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
fle2-*tests expecting the QEv1 protocol.fle2v2-*tests expecting the QEv2 protocol.Changes are tested with this patch build
Background & Motivation
See DRIVERS-2435.